package com.itboye.hutouben.responsitory;

import com.google.gson.reflect.TypeToken;
import com.itboye.hutouben.bean.GoodsDetailBean;
import com.itboye.hutouben.volley.BaseErrorListener;
import com.itboye.hutouben.volley.BaseNetRepository;
import com.itboye.hutouben.volley.BaseSuccessReqListener;
import com.itboye.hutouben.volley.ByJsonRequest;
import com.itboye.hutouben.volley.ICompleteListener;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by boye009 on 2016/12/6.
 */

public class GoodsResponsitory extends BaseNetRepository {
    final String APIKEY = "102";
    final String GoodsDetail = "By_Product_detail";

    public GoodsResponsitory(ICompleteListener iCompleteListener) {
        super(iCompleteListener);
    }

    public void detailInfo(String pid) {
        Type type = new TypeToken<GoodsDetailBean>() {
        }.getType();
        String apiVer = "102";
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("id", pid);
        (new ByJsonRequest.Builder<GoodsDetailBean>())
                .setTypeVerParamsAndReturnClass(GoodsDetail, APIKEY, map, type)
                .requestListener(
                        new BaseSuccessReqListener<GoodsDetailBean>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

}
